/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alessandro
 */
@Entity
@Table(name = "sentnotification")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sentnotification.findAll", query = "SELECT s FROM Sentnotification s"),
    @NamedQuery(name = "Sentnotification.findByNotification", query = "SELECT s FROM Sentnotification s WHERE s.sentnotificationPK.notification = :notification"),
    @NamedQuery(name = "Sentnotification.findByUser", query = "SELECT s FROM Sentnotification s WHERE s.sentnotificationPK.user = :user"),
    @NamedQuery(name = "Sentnotification.findByRead", query = "SELECT s FROM Sentnotification s WHERE s.read = :read")})
public class Sentnotification implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SentnotificationPK sentnotificationPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "read")
    private int read;
    @JoinColumn(name = "notification", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Notification notification1;
    @JoinColumn(name = "user", referencedColumnName = "email", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private User user1;

    public Sentnotification() {
    }

    public Sentnotification(SentnotificationPK sentnotificationPK) {
        this.sentnotificationPK = sentnotificationPK;
    }

    public Sentnotification(SentnotificationPK sentnotificationPK, int read) {
        this.sentnotificationPK = sentnotificationPK;
        this.read = read;
    }

    public Sentnotification(int notification, String user) {
        this.sentnotificationPK = new SentnotificationPK(notification, user);
    }

    public SentnotificationPK getSentnotificationPK() {
        return sentnotificationPK;
    }

    public void setSentnotificationPK(SentnotificationPK sentnotificationPK) {
        this.sentnotificationPK = sentnotificationPK;
    }

    public int getRead() {
        return read;
    }

    public void setRead(int read) {
        this.read = read;
    }

    public Notification getNotification1() {
        return notification1;
    }

    public void setNotification1(Notification notification1) {
        this.notification1 = notification1;
    }

    public User getUser1() {
        return user1;
    }

    public void setUser1(User user1) {
        this.user1 = user1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sentnotificationPK != null ? sentnotificationPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sentnotification)) {
            return false;
        }
        Sentnotification other = (Sentnotification) object;
        if ((this.sentnotificationPK == null && other.sentnotificationPK != null) || (this.sentnotificationPK != null && !this.sentnotificationPK.equals(other.sentnotificationPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Sentnotification[ sentnotificationPK=" + sentnotificationPK + " ]";
    }
    
}
